HAL DMA2D migration: List of applicable concepts

This section provides information about the HAL DMA2D applicable architecture concepts.

Concepts for DMA2D

Concept

Description

Separation of initialization and configuration functions

The Initialization and the configuration has been split into 2 level functions:

  • HAL_DMA2D_Init(): initializes the handle and links it to a DMA2D instance.

  • HAL_DMA2D_SetConfigXXX(): manages the foreground and background settings depending on the chosen transfer mode:

    • HAL_DMA2D_SetConfigMemCopy(): configure a transfer for memory-to-memory without pixel format conversion.

    • HAL_DMA2D_SetConfigMemCopyPFC(): configure a transfer for memory-to-memory with pixel format conversion.

    • HAL_DMA2D_SetConfigMemFill(): configure a transfer for memory fill with a fixed color.

    • HAL_DMA2D_SetConfigBlending(): configure a transfer with blending of the two inputs (foreground and background).

    • HAL_DMA2D_SetConfigBlendingWithFGColor(): configure a transfer for blending an image from the background input with a fixed color on the foreground input.

    • HAL_DMA2D_SetConfigBlendingWithBGColor(): configure a transfer for blending an image from the foreground input with a fixed color on the background input.

Removal and conversion of init structure to configuration structure

The initialization and layer configuration structures has been replaced by four configuration structures each tailored for a specific mode:

  • hal_dma2d_mem_copy_config_t: for memory-to-memory transfer with or without pixel format conversion.

  • hal_dma2d_mem_fill_config_t: for register to memory transfers.

  • hal_dma2d_blending_config_t: for a transfer with blending of the foreground and background input images.

  • hal_dma2d_blending_fixed_color_config_t: for a transfer with blending of one of the input sources image(foreground or background) and a fixed color on the other input.

Renaming of the handle structure

The handle structure has been renamed to hal_dma2d_handle_t.

Remove MspInit and MspDeInit callbacks

The functions HAL_DMA2D_MspInit() and HAL_DMA2D_MspDeInit() has been removed and replaced by a user-defined sequence.

Unitary configuration APIs

New APIs has been introduced to get and set DMA2D features.

Individual callback registration APIs replace global register and unregister functions

Specific functions manage callback registration for each DMA2D event, enabling the registration of callback functions for various DMA2D events.

Introduce specialized IRQ handlers

HAL_DMA2D_IRQHandler is still available in HAL2.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL DMA2D driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The DMA2D Driver uses a state machine to manage its operations. The states are :

  • HAL_DMA2D_STATE_RESET

  • HAL_DMA2D_STATE_IDLE

  • HAL_DMA2D_STATE_XFER_ACTIVE

  • HAL_DMA2D_STATE_XFER_SUSPEND

  • HAL_DMA2D_STATE_CLUT_LOADING_ACTIVE

  • HAL_DMA2D_STATE_CLUT_LOADING_SUSPEND

Revised and optimized HAL API status returns

The HAL DMA2D functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Rename the error management function to HAL_DMA2D_GetLastErrorCodes().

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL DMA2D driver have been removed and replaced by _t.

Assertion implementation and usage in HAL1

The ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros are used to check the parameters and state of the HAL DMA2D driver.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including DMA2D instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL DMA2D functions start with HAL_DMA2D. All HAL DMA2D enums and structs start with hal_dma2d.

Other HAL DMA2D changes

Concept

Consideration

Remove obsolete functions.

  • in HAL2, obsolete functions like HAL_DMA2D_CLUTLoad(), HAL_DMA2D_CLUTLoad_IT() and HAL_DMA2D_ConfigCLUT() have been removed.

  • Instead, HAL_DMA2D_StartCLUTLoad() and HAL_DMA2D_StartCLUTLoad_IT() functions are introduced to handle the CLUT configuration and start.

Split the HAL_DMA2D_PollForTransfer() function and remove the DMA2D multi-source transfer functions.

  • HAL_DMA2D_PollForTransfer() function has been split into HAL_DMA2D_PollForTransfer() to monitor the DMA2D transfer completion and HAL_DMA2D_PollForCLUTLoad() to monitor the DMA2D CLUT loading transfer completion.

  • HAL_DMA2D_BlendingStart() and HAL_DMA2D_BlendingStart_IT() functions have been removed as the user can rely on HAL_DMA2D_Start() and HAL_DMA2D_Start_IT() functions to start the transfer.